package com.wbdbyte.controller;

import com.wbdbyte.entity.Product;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 获取商品列表
 */
@RestController
@RequestMapping("/product")
public class ProductController {
    @GetMapping("/list")
    public Map list() {
        //模拟查询商品的逻辑
        Product product = new Product();
        product.setProductName("xiaomi");
        product.setProductPrice(new BigDecimal(2.0));
        product.setProductStock(100);

        HashMap<String, Object> resultMap = new HashMap<>();
        resultMap.put("code", 000);
        resultMap.put("message", "成果");
        resultMap.put("date", Arrays.asList(product));
        return resultMap;
    }
}
